if Stygian.balances.sip == nil then Stygian.balances.sip = 1 end
if Stygian.sipHealth == nil then Stygian.sipHealth = 10000 end
if Stygian.sipMana == nil then Stygian.sipMana = 10000 end
if Stygian.sipEgo == nil then Stygian.sipEgo = 10000 end
if Stygian.maxHealth == nil then Stygian.maxHealth = 10000 end
if Stygian.maxMana == nil then Stygian.maxMana = 10000 end
if Stygian.maxEgo == nil then Stygian.maxEgo = 10000 end
function sipPrompt()
	local Stygian_brightPrompt = Stygian.config.brightPrompt
  if not Stygian.promptGag then
    SDebug("sipper", "Ok, we're not gagging the prompt")
  	local Stygian_brightPrompt = Stygian.config.brightPrompt
  	if Stygian_brightPrompt then
    	if Stygian.tracking ~= 1 then
    		setFgColor(80,80,80)
    	else
    		setFgColor(150,50,150)
    	end
    	echo( " Sipper:")
    	if Stygian.balances.sip == 0 then
    		setFgColor( 80, 80, 80 )
    	else
    		setFgColor(50,150,50)
    	end
    	echo(" E")
    	if Stygian.balances.salve ~= 1 then
    		setFgColor( 80, 80, 80 )
    	else
    		setFgColor(50,150,50)
    	end
    	echo(" S")
    	if Stygian.balances.herb ~= 1 then
    		setFgColor( 80, 80, 80 )
    	else
    		setFgColor(50,150,50)
    	end
    	echo(" H")
    else
      if Stygian.tracking ~= 1 then
    		setFgColor(175,0,0)
    	else
    		setFgColor(80,80,80)
    	end
    	echo( " Sipper:")
    	if Stygian.balances.sip == 0 then
    		setFgColor( 175, 0, 0 )
    	else
    		setFgColor(80,80,80)
    	end
    	echo(" E")
    	if Stygian.balances.salve ~= 1 then
    		setFgColor( 175, 0, 0 )
    	else
    		setFgColor(80,80,80)
    	end
    	echo(" S")
    	if Stygian.balances.herb ~= 1 then
    		setFgColor( 175, 0, 0 )
    	else
    		setFgColor(80,80,80)
    	end
    	echo(" H")
    end
  else
    SDebug("sipper", "Ok, we gagged a prompt here")
    deleteLine()
  end

 if Stygian.tracking ~= 1 then echo(" (sipper disabled) ") return end

	if Stygian.balances.sip == 1 then
	  SDebug("sipper", "We have sipping balance")
    if Stygian_brightPrompt then
      SDebug("sipper", "We've configured a bright prompt")
  		if Stygian.curHealth <= Stygian.sipHealth then
        SDebug("sipper", "We need to sip health")
  			setFgColor(150,50,150)
  			echo(" SIPPING: ")
  			setFgColor(255,255,150)
  			echo("health")
  			send("sip health")
  			Stygian.balances.sip = 0.5
  			tempTimer(1, [[if Stygian.balances.sip == 0.5 then Stygian.balances.sip = 1 end]])
  		elseif Stygian.curEgo <= Stygian.sipEgo then
  		  SDebug("sipper", "We need to sip bromides!")  		
  			setFgColor(150,50,150)
  			echo(" SIPPING: ")
  			setFgColor(255,255,150)
  			echo("bromide")
  			send("sip bromide")
  			Stygian.balances.sip = 0.5
  			tempTimer(1, [[if Stygian.balances.sip == 0.5 then Stygian.balances.sip = 1 end]])
  		elseif Stygian.curMana <= Stygian.sipMana then
  		  SDebug("sipper","we need to sip mana")
  			setFgColor(150,50,150)
  			echo(" SIPPING: ")
  			setFgColor(255,255,150)
  			echo("mana")
  			send("sip mana")
  			Stygian.balances.sip = 0.5
  			tempTimer(1, [[if Stygian.balances.sip == 0.5 then Stygian.balances.sip = 1 end]])
  		end
    else
      SDebug("sipper", "we have configured a not-bright prompt")
      if Stygian.curHealth <= Stygian.sipHealth then
        SDebug("sipper", "We need to sip health")
  			setFgColor(80,80,80)
  			echo(" SIPPING: ")
  			setFgColor(255,255,150)
  			echo("health")
  			send("sip health")
  			Stygian.balances.sip = 0.5
  			tempTimer(1, [[if Stygian.balances.sip == 0.5 then Stygian.balances.sip = 1 end]])
  		elseif Stygian.curEgo <= Stygian.sipEgo then
  		  SDebug("sipper", "We need to sip bromides!")
  			setFgColor(80,80,80)
  			echo(" SIPPING: ")
  			setFgColor(255,255,150)
  			echo("bromide")
  			send("sip bromide")
  			Stygian.balances.sip = 0.5
  			tempTimer(1, [[if Stygian.balances.sip == 0.5 then Stygian.balances.sip = 1 end]])
  		elseif Stygian.curMana <= Stygian.sipMana then
  		  SDebug("sipper","we need to sip mana")
  			setFgColor(80,80,80)
  			echo(" SIPPING: ")
  			setFgColor(255,255,150)
  			echo("mana")
  			send("sip mana")
  			Stygian.balances.sip = 0.5
  			tempTimer(1, [[if Stygian.balances.sip == 0.5 then Stygian.balances.sip = 1 end]])
  		else
  		  SDebug("sipper", "We need to sip nothing")
  		end
	  end
  end
	deselect()
	resetFormat()
end

function Stygian_sip_init()  
  Stygian.balances.sip = 1
  send("score")
  Stygian.sipHealth = math.floor(Stygian.maxHealth * Stygian.sipHealthLevel)
  Stygian.sipMana = math.floor(Stygian.maxMana * Stygian.sipManaLevel)
  Stygian.sipEgo = math.floor(Stygian.maxEgo * Stygian.sipEgoLevel)
end

